<%= error_messages_for :collection %>

<%= form_for(@collection, :html => {:multipart => true}) do |collection_form| %>
  <fieldset>
	<legend>Header</legend>
		<dl>
	   
	 	<% if @collection.new_record? && current_user.pseuds.size > 1 %>
      <dt><%= label_tag "owner_pseuds[]", ts("Select owner pseudonym(s)") %>:</dt>
      <dd><%= select_tag "owner_pseuds[]", options_from_collection_for_select(current_user.pseuds, :id, :name, current_user.default_pseud), :multiple => true %></dd>
    <% else %>
      <p><%= hidden_field_tag "owner_pseuds[]", [current_user.default_pseud.id] %></p>
    <% end %>
  
    <dt><%= collection_form.label :icon %></dt>
    <dd><%= collection_form.file_field :icon %></dd>

  <% if @collection.children.empty? %>
	<dt>
    <%= collection_form.label :parent_name, ts("Parent collection (must be one you maintain)") %>:</dt>
    <dd>
      <%= collection_form.text_field :parent_name %>
      <%= autocomplete_text_field("collection_parent_name", :no_comma => true) %>      
    </dd>
  <% end %>

    <dt><%= collection_form.label :name, ts("Collection Name* (letters, numbers, underscores)") %>:</dt>
    <dd><%= collection_form.text_field :name %></dd>


  <dt>
    <%= collection_form.label :title, ts("Display Title* (text only)") %>:</dt>
   <dd> <%= collection_form.text_field :title %></dd>

  <dt>
    <%= collection_form.label :email, ts("Email (optional, otherwise notices will go to owners)") %>:</dt>
    <dd><%= collection_form.text_field :email, :size => 40 %>
  </dd>
  <dt>
    <%= collection_form.label :header_image_url, ts("URL for custom header image (jpg, gif, png)") %>:</dt>
   <dd><%= collection_form.text_field :header_image_url %>
  </dd>
  <dt>
    <%= collection_form.label :description, ts("Brief Description") %>:</dt>
    <dd>
<%= collection_form.text_area :description, :rows => 4, :cols => 60, :class => "description-field" %>
    <%= live_validation_for_field('collection_description', :presence => false, :maximum_length => ArchiveConfig.SUMMARY_MAX) %>
    <%= generate_countdown_html("collection_description", ArchiveConfig.SUMMARY_MAX) %>
  </dd>
</dl>
</fieldset>
  <% @collection.build_collection_preference unless @collection.collection_preference %>
  <%= collection_form.fields_for :collection_preference do |preference_form| %>
<fieldset>
	<legend>Preferences</legend>
    <dl>
	<dt><%= preference_form.label :moderated, ts("Is this collection moderated?") %> <%= link_to_help "moderated-collection" %></dt>
    <dd><%= preference_form.check_box :moderated %>
  </dd>
  <dt>
    <%= preference_form.label :closed, ts("Is this collection closed?") %></dt>
    <dd><%= preference_form.check_box :closed %></dd>
  <dt>
    <%= preference_form.label :unrevealed, ts("Is this collection currently unrevealed?") %></dt>
   <dd><%= preference_form.check_box :unrevealed %>
  </dd>
  <dt>
    <%= preference_form.label :anonymous, ts("Is this collection currently anonymous?") %></dt>
    <dd><%= preference_form.check_box :anonymous %>
  </dd>
  <dt>
    <%= preference_form.label :show_random, ts("Would you like to show random stories on the front page instead of the most recent?") %>
  </dt>
  <dd>
    <%= preference_form.check_box :show_random %>
  </dd>  
  <dt><%= label_tag :challenge_type, ts("If this collection is for a challenge, please choose the type") %>:</dt>
    <dd><%= select_tag :challenge_type, options_for_select(Collection::CHALLENGE_TYPE_OPTIONS, @collection.challenge ? @collection.challenge.class.name : "") %></dd>
</dl>
</fieldset>
  <% end %>

  <% @collection.build_collection_profile unless @collection.collection_profile %>
  <%= collection_form.fields_for :collection_profile do |profile_form| %>
  <fieldset class="preface profile">
		<legend>Profile</legend>
		<p class="note">
    Quick tip: if this is a subcollection or challenge, and you leave any of the following fields blank, they will be 
    inherited from the parent collection, so you don't need to repeat shared information.
    </p>
    <p><%= allowed_html_instructions %></p>
    <h3><%= profile_form.label :intro, ts("Introduction") %>:</h3>
  	<p>
      <%= profile_form.text_area :intro, :rows => 10, :cols => 80 %>
      <%= live_validation_for_field('collection_collection_profile_attributes_intro', :presence => false, :maximum_length => ArchiveConfig.INFO_MAX) %>
      <%= generate_countdown_html("collection_collection_profile_attributes_intro", ArchiveConfig.INFO_MAX) %>
    </p>

      <h3><%= profile_form.label :faq, ts("FAQ") %>:</h3>
      <p><%= profile_form.text_area :faq, :rows => 10, :cols => 80 %>
      <%= live_validation_for_field('collection_collection_profile_attributes_faq', :presence => false, :maximum_length => ArchiveConfig.INFO_MAX) %>
      <%= generate_countdown_html("collection_collection_profile_attributes_faq", ArchiveConfig.INFO_MAX) %>
    </p>
    <h3>
      <%= profile_form.label :rules, ts("Rules") %>:</h3>
      <p><%= profile_form.text_area :rules, :rows => 10, :cols => 80 %>
      <%= live_validation_for_field('collection_collection_profile_attributes_rules', :presence => false, :maximum_length => ArchiveConfig.INFO_MAX) %>
      <%= generate_countdown_html("collection_collection_profile_attributes_rules", ArchiveConfig.INFO_MAX) %>
    </p>

    <h3><%= profile_form.label :assignment_notification, ts("Assignment Notification Message") %>:</h3>
    <p class="note">
      (This message will be appended to the assignment notifications sent out when you assign a challenge. Plain text only.)
    </p>
  	<p>
      <%= profile_form.text_area :assignment_notification, :rows => 10, :cols => 80 %>
      <%= live_validation_for_field('collection_collection_profile_attributes_assignment_notification', :presence => false, :maximum_length => ArchiveConfig.SUMMARY_MAX) %>
      <%= generate_countdown_html("collection_collection_profile_attributes_assignment_notification", ArchiveConfig.SUMMARY_MAX) %>
    </p>

    <h3><%= profile_form.label :gift_notification, ts("Gift Notification Message") %>:</h3>
    <p class="note">
      (This message will be appended to the story notifications sent out when you reveal the stories in a gift exchange. Plain text only.)
    </p>
  	<p>
      <%= profile_form.text_area :gift_notification, :rows => 10, :cols => 80 %>
      <%= live_validation_for_field('collection_collection_profile_attributes_gift_notification', :presence => false, :maximum_length => ArchiveConfig.SUMMARY_MAX) %>
      <%= generate_countdown_html("collection_collection_profile_attributes_gift_notification", ArchiveConfig.SUMMARY_MAX) %>
    </p>

  <% end %>
 </fieldset>
<fieldset>
	<legend><%h= 'Submit' %></legend> 
  <p class="submit">
    <%= collection_form.submit 'Submit' %>
  </p>
</fieldset>
<% end %>
